package me.like.diandian.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.core.app.ActivityCompat;

import me.like.diandian.R;
import me.like.diandian.base.BaseActivity;
import me.like.diandian.databinding.ActivityClearBinding;
import me.like.diandian.util.DataCleanManager;
import me.like.diandian.view.ToastView;

/**
 * Created by shousakai on 2019/6/21.
 */

public class ClearActivity extends BaseActivity<ActivityClearBinding> {
    @Override
    protected int getLayoutId() {
        return R.layout.activity_clear;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding.tlvTitle.setTitle("清除缓存");
        binding.tlvTitle.setBackgroundColor(ActivityCompat.getColor(this,R.color.white));
        binding.tlvTitle.setLeftimgtype(2);
        try {
            binding.setSpace(DataCleanManager.getTotalCacheSize(this));
        } catch (Exception e) {
            e.printStackTrace();
        }
        onClick(binding.tvClear, v -> {
            DataCleanManager.getTotalCacheSize(this);
            ToastView.initToast().textToast(this, "清除缓存成功");
            binding.setSpace("0K");
        });

        setstateBar(true);
    }

    public static void launch(Context context) {
        Intent intent = new Intent(context, ClearActivity.class);
        context.startActivity(intent);
    }
}
